import java.util.Arrays;

public class Test
{
    public boolean equals(double[][] matrix1, double[][] matrix2)
    {
        if (!(matrix1.length == matrix2.length || (matrix1[0].length == matrix2[0].length)))
        {
            return false;
        }
        boolean flag = true;
        for (int i = 0; i < matrix1.length; i++)
        {
            for (int j = 0; j < matrix1[0].length; j++)
            {
                if (matrix1[i][j] != matrix2[i][j])
                {
                    flag = false;
                    break;
                }
            }
            if (!flag)
                break;
        }
        return flag;
    }

    public static void main(String[] args)
    {
        double[][] matrix1 = new MatrixGenerator(300, 400).getMatrix();
        double[][] matrix2 = new MatrixGenerator(400, 500).getMatrix();
        double[][] result_singleThread;
        long time0 = System.currentTimeMillis();
        result_singleThread = new MatrixMultiply(matrix1, matrix2).multiply();
        long time1 = System.currentTimeMillis();
        System.out.println("单线程矩阵乘法所用时间：" + (time1 - time0) / 1000.0 + "秒");
        double[][] result_multiThread;
        time0 = System.currentTimeMillis();
        result_multiThread = new MatrixMultiply(matrix1, matrix2).multiply(4);
        time1 = System.currentTimeMillis();
        assert new Test().equals(result_singleThread, result_multiThread);
        System.out.println("多线程矩阵乘法所用时间：" + (time1 - time0) / 1000.0 + "秒");
    }
}
